{# ----------------------------------------------------------------------------
 # SymForce - Copyright 2022, Skydio, Inc.
 # This source code is under the Apache 2.0 license found in the LICENSE file.
 # ---------------------------------------------------------------------------- #}

  {# Handwritten methods for Pose2 #}
  template <typename Derived>
  Pose2(const Rot2<Scalar>& rotation, const Eigen::MatrixBase<Derived>& position) {
    static_assert(Derived::RowsAtCompileTime == 2, "Position must be a 2x1 vector");
    static_assert(Derived::ColsAtCompileTime == 1, "Position must be a 2x1 vector");
    data_.template head<2>() = rotation.Data();
    data_.template tail<2>() = position;
  }

  // Generate a random element, with normally distributed position
  template <typename Generator>
  static Pose2 Random(Generator& gen) {
    return Pose2(Rot2<Scalar>::Random(gen), sym::StorageOps<Vector2>::Random(gen));
  }

  Eigen::Transform<Scalar, 2, Eigen::TransformTraits::Isometry> ToTransform() const {
    return Eigen::Transform<Scalar, 2, Eigen::TransformTraits::Isometry>{ToHomogenousMatrix()};
  }
